// pages/stock/stock-rep-detail/stock-rep-detail.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    data:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let id = options.id;
    let that = this;
    app.post('/shop/getStockDetail',{restockBn:id}).then(res=>{
      that.setData({
        data: res
      })
    })
  },
  confirm:function(){
    let that = this;
    let id = that.data.data.restockBn;
    wx.showModal({
      title: '确认收货提醒',
      content: '是否确定已经收货',
      success:function(){
        app.post('/shop/confirmStock', { restockBn: id}).then(res=>{
          wx.showToast({
            title: '收货成功', 
            success: res => {
              that.onLoad({ id: id})
            }
          })
        },res=>{
          wx.showToast({
            title: '收货失败',
          })
        })
      }
    })
  },
  call: function () {
    let that = this;
    wx.makePhoneCall({
      phoneNumber: that.data.data.phone,
      success: function () {
        console.log("成功拨打电话")
      }
    })
  }

})